<?php
date_default_timezone_set('America/Mexico_City');
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * Description of Idiorm
 *
 * @author francisco
 */
class Idiorm {
    function __construct() {
        require_once('ORM/idiorm' . EXT);
        if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
		{
			if ( ! file_exists($file_path = APPPATH.'config/database.php'))
			{
				show_error('The configuration file database.php does not exist.');
			}
		}
		include($file_path);
		if ( ! isset($db) OR count($db) == 0)
		{
			show_error('No database connection settings were found in the database config file.');
		}
		ORM::configure(array(
        'connection_string' => sprintf('%s:host=%s;dbname=%s',
        $db['default']['dbdriver'],
        $db['default']['hostname'],
        $db['default']['database']), 
        'username' => $db['default']['username'], 
        'password' => $db['default']['password']
    ));
    }
}
?>